﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

using Rockfan.Framework;
using Rockfan.Framework.Audio;
using Rockfan.Framework.Entities;
using Rockfan.Framework.Graphics;

namespace Rockfan
{
    public sealed class RockfanGame : Game
    {
        public RockfanGame()
        {
            graphics = new GraphicsDeviceManager(this);
            graphics.SynchronizeWithVerticalRetrace = false;
            graphics.GraphicsProfile = GraphicsProfile.HiDef;            
            this.IsFixedTimeStep = false;

#if Debug
            graphics.PreferredBackBufferWidth = 1280;
            graphics.PreferredBackBufferHeight = 720;       
     
            graphics.SynchronizeWithVerticalRetrace = false;
            this.IsFixedTimeStep = false;
#endif

#if Release
            graphics.PreferredBackBufferWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
            graphics.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
            
            graphics.IsFullScreen = true;
            graphics.PreferMultiSampling = true;

            this.IsFixedTimeStep = false;
            graphics.SynchronizeWithVerticalRetrace = true;
#endif

            //graphics.PreparingDeviceSettings += OnGraphicsPreperation;
        }

        void OnGraphicsPreperation(object sender, PreparingDeviceSettingsEventArgs e)
        {
            var pp = e.GraphicsDeviceInformation.PresentationParameters;
            pp.MultiSampleCount = 0;
        }

        protected override void Initialize()
        {
            EngineServices.Initialize(this);            

            base.Initialize();
        }

        protected override void LoadContent()
        {
            Theme.LoadTheme("Default");
            SceneManager.StartScene(typeof(Scenes.Gamescene).FullName);
            GraphicsDevice.RasterizerState = RasterizerState.CullNone;

            base.LoadContent();
        }

        protected override void Update(GameTime gameTime)
        {


            base.Update(gameTime);
        }

        protected override void UnloadContent()
        {
            
            base.UnloadContent();
        }

        private GraphicsDeviceManager graphics;
    }
}
